package com.wenx.concurrent;

/**
 * Created by wenx on 2019-10-09 14:16
 */
public class BankServiceWindowSharedTest {
    public static void main(String[] args) {
        BankServiceWindowShared bankServiceWindow = new BankServiceWindowShared(2);
        Thread tom = new Thread(() -> {
            bankServiceWindow.handle();
            System.out.println("tom开始办业务");
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("tom结束办理");
            bankServiceWindow.unHandle();
        });
        Thread jim = new Thread(() -> {
            bankServiceWindow.handle();
            System.out.println("jim开始办业务");
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("jim结束办理");
            bankServiceWindow.unHandle();
        });
        Thread jay = new Thread(() -> {
            bankServiceWindow.handle();
            System.out.println("jay开始办业务");
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("jay结束办理");
            bankServiceWindow.unHandle();
        });
        tom.start();
        jay.start();
        jim.start();
    }
}